package com.isdust.jy.mbank;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.isdust.jy.mbank.base.BaseActivity;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class MainActivity extends BaseActivity {
    private static String sdata;
    static {
        Date d=new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd+H:m");
        sdata = format.format(d);
    }


    String rawurl="http://123.206.88.145/blog";
    String rawurl2="http://192.168.137.145/html/blog";
    String url=rawurl+"/admin/login.php?referer=http%3A%2F%2F192.168.137.145%2Fhtml%2Fblog%2Fadmin%2F";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        final String url1=rawurl+"/index.php/action/login?_=a6ed9257f65d334066a0906637837ea0";
        final String data="name=admin&password=forever&referer="+rawurl+"/admin/";
        new Thread(){
            @Override
            public void run() {
                super.run();
                try {
                    //String rawdata=util.get_string(url);
                    String rawdata=util.post_string(url1,data);
                    Log.i("TAG===========",rawdata);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }.start();


        new Thread(){
            @Override
            public void run() {
                super.run();

                try {
                    Thread.sleep(6*100);
                    String url=rawurl+"/index.php/action/contents-post-edit?_=9747a141ea49835abfe8ed046a78dd16";
                    String postdata="title=phonetest&text=test&fieldName[]= &fieldTypes[]= &fieldValues[]= &cid=50&do=publish&markdown=1&date="+sdata+"&tags= &visibility=publish&password= &allowComment=1&allowPing=1&allowFeed=1&trackback=";
                    String rawdata=util.post_string(url,postdata);
                   // String rawdata=util.post_string(url1,data);
                    Log.i("TAG===========",rawdata);
                } catch (IOException e) {
                    e.printStackTrace();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }

    @Override
    protected boolean hasActionBar() {
        return false;
    }

    @Override
    protected boolean hasBackButton() {
        return true;
    }
}
